﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using VK.Comm;

namespace VK.Casemeet.Members
{
    public static class MemberHelper
    {
        public static void BindSexRad(RadioButtonList rad)
        {
            rad.Items.Clear();
            rad.Items.Add(new ListItem("男", "1"));
            rad.Items.Add(new ListItem("女", "2"));
            rad.DataBind();
            rad.SelectedIndex = 1;
        }

        public static string GetSexLabel(int type)
        {
            string result = string.Empty;
            switch (type)
            {
                case 1: result = "男"; break;
                case 2: result = "女"; break;
            }
            return result;
        }

        public static void BindProfessionDDL(DropDownList control, OptionType optionType)
        {
            control.Items.Clear();
            control.Items.Add(new ListItem("上班族", "1"));
            control.Items.Add(new ListItem("公务员", "2"));
            control.Items.Add(new ListItem("学生", "3"));
            control.Items.Add(new ListItem("自由职业者", "4"));
            control.Items.Add(new ListItem("企业高管", "5"));
            control.Items.Add(new ListItem("私营业主", "6"));
            control.Items.Add(new ListItem("其他", "7"));
            switch (optionType)
            {
                case OptionType.Default: break;
                case OptionType.Search: control.Items.Insert(0, new ListItem("全部", "0")); break;
                case OptionType.Select: control.Items.Insert(0, new ListItem("请选择", "0")); break;
            }
            control.SelectedIndex = 0;
        }

        public static void BindEducationDDL(DropDownList control, OptionType optionType)
        {
            control.Items.Clear();
            control.Items.Add(new ListItem("小学", "1"));
            control.Items.Add(new ListItem("中学", "2"));
            control.Items.Add(new ListItem("高中", "3"));
            control.Items.Add(new ListItem("大专", "4"));
            control.Items.Add(new ListItem("本科", "5"));
            control.Items.Add(new ListItem("硕士", "6"));
            control.Items.Add(new ListItem("博士及更高", "7"));
            switch (optionType)
            {
                case OptionType.Default: break;
                case OptionType.Search: control.Items.Insert(0, new ListItem("全部", "0")); break;
                case OptionType.Select: control.Items.Insert(0, new ListItem("请选择", "0")); break;
            }
            control.SelectedIndex = 0;
        }

        public static void BindIncomeDDL(DropDownList control, OptionType optionType)
        {
            control.Items.Clear();
            control.Items.Add(new ListItem("2000元以下", "1"));
            control.Items.Add(new ListItem("2000-5000元", "2"));
            control.Items.Add(new ListItem("5000-8000元", "3"));
            control.Items.Add(new ListItem("8000-10000元", "4"));
            control.Items.Add(new ListItem("10000-15000元", "5"));
            control.Items.Add(new ListItem("更高", "6"));
            switch (optionType)
            {
                case OptionType.Default: break;
                case OptionType.Search: control.Items.Insert(0, new ListItem("全部", "0")); break;
                case OptionType.Select: control.Items.Insert(0, new ListItem("请选择", "0")); break;
            }
            control.SelectedIndex = 0;
        }

        public static void BindMarriageDDL(DropDownList control, OptionType optionType)
        {
            control.Items.Clear();
            control.Items.Add(new ListItem("未婚", "1"));
            control.Items.Add(new ListItem("已婚", "2"));
            switch (optionType)
            {
                case OptionType.Default: break;
                case OptionType.Search: control.Items.Insert(0, new ListItem("全部", "0")); break;
                case OptionType.Select: control.Items.Insert(0, new ListItem("请选择", "0")); break;
            }
            control.SelectedIndex = 0;
        }

        public static ListItem[] StateData = new ListItem[3]{
            new ListItem("未激活", "1"),
            new ListItem("正常", "2"),
            new ListItem("停用", "3")
        };

        public static void BindStateDDL(DropDownList control, OptionType optionType)
        {
            control.Items.Clear();
            control.Items.AddRange(StateData);
            switch (optionType)
            {
                case OptionType.Default: break;
                case OptionType.Search: control.Items.Insert(0, new ListItem("全部", "0")); break;
                case OptionType.Select: control.Items.Insert(0, new ListItem("请选择", "0")); break;
            }
            control.SelectedIndex = 0;
        }

        public static string GetStateLabel(int state)
        {
            string result = string.Empty;
            var items = StateData.Where(p => p.Value == state.ToString());
            if (items.Count() > 0)
            {
                result = items.First().Text;
            }
            return result;
        }
    }
}
